var a = ["11", "12", "13"];
window.onload = show;
function rightIn() {
    var b = document.getElementById("getNumber").value;
    var g=b.split(",");
    console.log(g);
    for(var i=0;i<g.length;i++){
    a.push(g[i]);
    }
    change();
	show();

}
function leftIn() {
    var b = document.getElementById("getNumber").value;	
    var g=b.split(",");
    console.log(g);
    for(var i=0;i<g.length;i++){
    a.unshift(g[i]);
    }
    change();
	show();

}
function leftOut() {
    var b = document.getElementById("getNumber").value;
    a.shift(b);
    change();
	show();
}
function rightOut() {
    var b = document.getElementById("getNumber").value;
    a.pop(b);
    change();
	show();
}
function show() {
	console.log("123");
	var n=a.length;
	for (var i = 0; i < a.length; i++) {
		console.log("123");
		var append = document.getElementById("box");
		var newNode = document.createElement("div");
		newNode.setAttribute("class", "number");
		newNode.innerHTML = a[i];
		append.appendChild(newNode);
		newNode.onclick = foo; 
	}	
}
function change(){
	var append = document.getElementById("box");
	    while(append.hasChildNodes()) //当div下还存在子节点时 循环继续
    {
        append.removeChild(append.firstChild);
    }
}
function foo(event){
	console.log(event);
	event.target.parentNode.removeChild(event.target);

}
function search(){
    var m;
    var c = document.getElementById("search").value;
    console.log(c);
    change();
    for(var i=0; i<a.length;i++){
        m = a[i].split("");
        console.log(a[i]);
        for(var k=0;k<m.length;k++){
            for (var n=k;n<m.length;n++){
                var f = a[i].substring(k,n+1);
                console.log(f);
            if(c==f){
             var append = document.getElementById("box");
             var newNode = document.createElement("div");
             newNode.setAttribute("class", "number");
             newNode.innerHTML = a[i];
             append.appendChild(newNode);
             newNode.onclick = foo; 
             continue;
         }
            }

/*          var g = a[i].substring(0,k+1);
            var r = a[i].substring(k,k+1);
            if(g==c){
             var append = document.getElementById("box");
             var newNode = document.createElement("div");
             newNode.setAttribute("class", "number");
             newNode.innerHTML = a[i];
             append.appendChild(newNode);
             newNode.onclick = foo; 
             break;
            }
            if(r==c){
             var append = document.getElementById("box");
             var newNode = document.createElement("div");
             newNode.setAttribute("class", "number");
             newNode.innerHTML = a[i];
             append.appendChild(newNode);
             newNode.onclick = foo; 
             break;
            }*/
        }

    }
}